package com.example.demo.demos.thread;


import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: lixz
 * @Date: 2024/07/29/16:58
 */
public class threadPool {
    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
                9,//核心线程数 不能小于0
                6,//最大的线程数量-减去核心线程=临时线程
                60, TimeUnit.SECONDS,//空闲线程的最大存活时间
                new ArrayBlockingQueue<>(3),//这里设置了上限,任务队列
                Executors.defaultThreadFactory(),//创建线程工厂
                new ThreadPoolExecutor.AbortPolicy()//任务的拒绝策略
        );

        poolExecutor.submit(new Runnable() {
            @Override
            public void run() {
                String s = "bbbb";
                System.out.println('"');
            }
        });

    }
}
